<template>
  <div>
  <el-dialog
    :title="true ? '选择地址' : ''"
    :close-on-click-modal="false"
    :visible.sync="visible"
    center
    >
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="init()">
      <!-- <el-form-item>
        <el-input v-model="dataForm.key" placeholder="地址名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="init()">查询</el-button>
      </el-form-item> -->
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @row-dblclick="rowDbClick"
      style="width: 100%;">
      <el-table-column
      type="index"
      width="50">
    </el-table-column>
      <el-table-column
        prop="name"
        header-align="center"
        align="center"
        label="地址名称">
       <template slot-scope="scope">
          {{scope.row.region.pnames}}, {{scope.row.region.name}} , {{scope.row.name}}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </el-dialog>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          key: ''
        },
        dataList: [],
        data: {
          selectId: '',
          selectText: ''
        },
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    computed: {
      regionId() {
        return this.$store.state.address.regionId;
      }
    },
    methods: {
      init () {
        this.visible = true
        this.getDataList()
      },
      getDataList () {
        this.dataListLoading = true
         this.$http({
          // url: this.$http.adornUrl('/dgactualunit/list'),
          url:'/dg-standard-info/dgstandardaddress/list',
          method: 'post',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'regionId': this.regionId,
            'name': this.dataForm.name
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      rowDbClick (row, column, event) {
        this.data.selectId = row.id
        this.data.selectText =row.region.pnames+ "," + row.region.name + "," + row.name
        this.$message({
          message: '选择成功',
          type: 'success',
          duration: 1000,
          onClose: () => {
            this.visible = false
            this.$emit('receiveParameters', this.data)
          }
        })
      }
    }
  }
</script>

<style>
.custom-3E8EF7 .el-form-item.is-required .el-form-item__label:before {
    font-size: 22px;
}
</style>

